home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / drdobbs / 1987 / 08 / shammlst.aug < prev    next >
Text File  |  1987-08-12  |  20KB  |  770 lines

  1.  
  2. Listing 1:  BASIC source code for the Sieve benchmark
  3.  
  4. 1000 ' Sieve Benchmark Test
  5. 1001 ' Version 1.0  5/30/86  Namir C. Shammas
  6. 1010 DEFINT A-Z
  7. 1020 SIZE = 7000
  8. 1030 MAXITER = 10
  9. 1040 TRUE = 1: FALSE = 0
  10. 1050 DIM  FLAGS(SIZE)
  11. 1060 PRINT "START ";MAXITER;" ITERATION"
  12. 1065 TIME$ = "00:00:00.00"
  13. 1070 FOR ITER = 1 TO MAXITER
  14. 1080    COUNT = 0
  15. 1090    FOR I = 0 TO SIZE
  16. 1100      FLAGS(I) = TRUE
  17. 1110    NEXT I
  18. 1120    FOR I = 0 TO SIZE
  19. 1130      IF FLAGS(I) <> TRUE THEN 1210
  20. 1140        PRIME = I+I+3
  21. 1150        K = I+PRIME
  22. 1160        WHILE K <= SIZE  
  23. 1170           FLAGS(K) = FALSE
  24. 1180           K = K + PRIME 
  25. 1190        WEND 
  26. 1200        COUNT = COUNT + 1
  27. 1210    NEXT I 
  28. 1220 NEXT ITER
  29. 1225 PRINT "Time is ";TIME$
  30. 1230 PRINT COUNT;" PRIMES"
  31. 1240 END 
  32.  
  33.  
  34.  
  35.  
  36. Listing 2: Translated C source code for the Sieve benchmark
  37.  
  38. char *TIME_(), *balloc(); 
  39. static int *FLAGS, count, false, i, iter, k, maxiter, prime, size, true; 
  40. static int it_1, it_2, it_3; 
  41. static char *st_1; 
  42. static int ml_1; 
  43. main(argc, argv) 
  44.     int argc; 
  45.     char *argv[]; 
  46.     { 
  47.     bio_init(argc, argv, 1); 
  48.     /* Sieve Benchmark Test */
  49.     /* Version 1.0  5/30/86  Namir C. Shammas */
  50.     size = 7000; 
  51.     maxiter = 10; 
  52.     true = 1; 
  53.     false = 0; 
  54.     ml_1 = size+1; 
  55.     bfree(FLAGS); 
  56.     FLAGS = (int*)balloc((long)sizeof(int) * (size+1)); 
  57.     BPRINT("s;i;s", "\006START ", maxiter, "\012 ITERATION"); 
  58.     STIME_("\01300:00:00.00"); 
  59.     it_1 = maxiter; 
  60.     
  61.     for (iter = 1; iter <= it_1; ++iter) 
  62.    count = 0; 
  63.    it_2 = size; 
  64.  
  65.    for (i = 0; i <= it_2; ++i) 
  66.    { 
  67.      FLAGS[i] = true; 
  68.    } 
  69.    it_3 = size; 
  70.  
  71.    for (i = 0; i <= it_3; ++i) 
  72.    { 
  73.      if (FLAGS[i] != true) 
  74.        goto l_1210; 
  75.      prime = i + i + 3; 
  76.      k = i + prime; 
  77.      while (k <= size) 
  78.      { 
  79.         FLAGS[k] = false; 
  80.         k = k + prime; 
  81.      } 
  82.      count = count + 1; 
  83.     
  84.      l_1210:; 
  85.     } 
  86.     BPRINT("s;s", "\010Time is ", TIME_(&st_1)); 
  87.     BPRINT("i;s", count, "\007 PRIMES"); 
  88.     bexit(0); 
  89.     bexit(0); 
  90.  
  91.  
  92.  
  93.  
  94. Listing 3: BASIC source code for a root-seeking program
  95.  
  96. 1010 DEFDBL A-H,P-Z
  97. 1020 DEFINT I-O
  98. 1030 DEF FNF(X) = EXP(X) - 3*X*X
  99. 1040 CLS
  100. 1050 INPUT "Enter guess : ";X : PRINT
  101. 1060 DATA 1.0E-08, 50
  102. 1070 READ Accuracy, MAX.ITER
  103. 1075 Iter = 0
  104. 1076 Diverge% = 1
  105. 1077 Diff = 2 * Accuracy
  106. 1078 WHILE ABS(Diff) > Accuracy
  107. 1080 ' Start root seeking method
  108. 1090   H = 0.01
  109. 1100   IF ABS(X) > 1 THEN H = H * X
  110. 1110   Diff = 2 * H * FNF(X) / (FNF(X+H) - FNF(X-H))
  111. 1120   X = X - Diff
  112. 1130   Iter = Iter + 1
  113. 1140   IF Iter > MAX.ITER THEN Diverge% = 0
  114. 1150 WEND
  115. 1155 IF (Diverge% = 0) THEN Accuracy = 10 * Accuracy : GOTO 1075
  116. 1160 PRINT USING "Root = +#.#######^^^^";X : PRINT
  117. 1170 PRINT USING "Number of iterations = ##";Iter : PRINT
  118. 1180 PRINT USING "Accuracy = #.###^^^^";Accuracy : PRINT
  119. 1190 END
  120.  
  121.  
  122.  
  123.  
  124. Listing 4: Translated C source code for a root-seeking program
  125.  
  126. typedef struct data 
  127.     { 
  128.     unsigned d_line; 
  129.     char *d_text; 
  130.     }DATA; 
  131. static DATA da_1[] = {1060, "1.0E-08, 50\n"}; 
  132. double ABS(), EXP(), f_raise(); 
  133. static int divergeI, iter, max_iter, n; 
  134. static double accuracy, diff, f, f0, f1, f2, h, x, x2; 
  135. DATA *data_stmts[] =  
  136.     { 
  137.     da_1, 0 
  138.     }; 
  139. main(argc, argv) 
  140.     int argc; 
  141.     char *argv[]; 
  142.     { 
  143.     bio_init(argc, argv, 1); 
  144.     CLS(); 
  145.     
  146. l_1040:; 
  147.     INPUT("P ;i", "\035Enter function number [1..3] ", &n); 
  148.     BPRINT(""); 
  149.      if (-((n < 1)) | -((n > 3))) 
  150.         goto l_1040; 
  151.     INPUT("P ;d", "\016Enter guess : ", &x); 
  152.     BPRINT(""); 
  153.     BREAD(" d,i", &accuracy, &max_iter); 
  154.     
  155. l_1075:; 
  156.     iter = 0; 
  157.     divergeI = 1; 
  158.     diff = 2 * accuracy; 
  159.     while (ABS(diff) > accuracy) 
  160.     { 
  161.     /* Start root seeking method */
  162.     h = 0.01; 
  163.      if (ABS(x) > 1) 
  164.         h = h * x; 
  165.     x2 = x; 
  166.     pr_1200(); 
  167.     f0 = f; 
  168.     x2 = x + h; 
  169.     pr_1200(); 
  170.     f1 = f; 
  171.     x2 = x - h; 
  172.     pr_1200(); 
  173.     f2 = f; 
  174.     diff = 2 * h * f0 / (f1 - f2); 
  175.     x = x - diff; 
  176.     iter = iter + 1; 
  177.      if (iter > max_iter) 
  178.         divergeI = 0; 
  179.     } 
  180.      if ((divergeI == 0)) 
  181.     { 
  182.     accuracy = 10 * accuracy; 
  183.     goto l_1075; 
  184.     } 
  185.     UPRINT("\025Root = +#.#######^^^^", "d", x); 
  186.     BPRINT(""); 
  187.     UPRINT("\032Number of iterations = ###", "i", iter); 
  188.     BPRINT(""); 
  189.     UPRINT("\024Accuracy = #.###^^^^", "d", accuracy); 
  190.     BPRINT(""); 
  191.     bexit(0); 
  192.     } 
  193.  
  194. pr_1200() 
  195.     { 
  196.     /* Subroutine to handle function catalogue */
  197.     switch (n) 
  198.     { 
  199.     case 1: 
  200.     pr_2100(); 
  201.     break; 
  202.     case 2: 
  203.     pr_2200(); 
  204.     break; 
  205.     case 3: 
  206.     pr_2300(); 
  207.     break; 
  208.     
  209.     } 
  210.     return; 
  211. /* Subroutine number 1 */
  212.         } 
  213.  
  214. pr_2100() 
  215.     { 
  216.     f = EXP(x2) - 3 * f_raise(x2, (double) 2); 
  217.     return; 
  218. /* Subroutine # 2 */
  219.         } 
  220.  
  221. pr_2200() 
  222.     { 
  223.     f = f_raise(x2, (double) 2) - 5 * x2 + 6; 
  224.     return; 
  225. /* Subroutine # 3 */
  226.         } 
  227.  
  228. pr_2300() 
  229.     { 
  230.     f = f_raise(x2, (double) 3) - 5 * x2 + 10; 
  231.     return; 
  232.     bexit(0); 
  233.     } 
  234.  
  235.  
  236.  
  237.  
  238. Listing 5: BASIC source code for Find/Replace utility.
  239.  
  240. 1000 ' Batch Find/Replace Utility  Version 1.1  2/7/86
  241. 1010 ' IBM PC                  BASICA version 2.0
  242. 1020 ' Copyright (c) 1987  Namir Clement Shammas
  243. 1030 '---------------------------------------------------
  244. 1040 OPTION BASE 1
  245. 1050 DEFINT A-Z
  246. 1060 DIM FILENAME$(20),FIND.STR$(30)
  247. 1070 DIM REPLACE.STR$(30),REPLACE.FLAG(30),TEXT.LINE$(500)
  248. 1080 '
  249. 1090 TRUE  = 1 : FALSE = 0 'Set true/false
  250. 1100 MAX.LINES = 500 ' Current maximum number of lines read from a file
  251. 1110 MAX.STRINGS = 30 ' Number of find/replace strings
  252. 1120 MAX.FILES = 20 ' Maximum number of files
  253. 1140 CLS
  254. 1150 '
  255. 1160 T$ = "BATCH FILE FIND/REPLACE PROGRAM" : GOSUB 2290
  256. 1170 T$ = "VERSION 1.0" : GOSUB 2290 : PRINT : PRINT
  257. 1180 GOSUB 1560 'GET.FILENAMES : Get filenames
  258. 1190 GOSUB 1820 'GET.STRINGS : Get search/replace strings
  259. 1200 FOR K = 1 TO NUM.FILES
  260. 1210   GOSUB 2060 ' READ.LINES: Read text lines from a file
  261. 1220   CHANGED = FALSE
  262. 1230   FOR I = 1 TO NUM.STRINGS
  263. 1240     FOUND = FALSE
  264. 1250     FOR J = 1 TO NUM.LINES
  265. 1260         PTR = INSTR(TEXT.LINE$(J),FIND.STR$(I))
  266. 1270         WHILE PTR > 0 
  267. 1280            IF (FOUND = TRUE) THEN 1330
  268. 1290               FOUND = TRUE
  269. 1300               LPRINT
  270. 1310               LPRINT "KEYWORD : ";FIND.STR$(I)
  271. 1330            LPRINT J;":";TEXT.LINE$(J)
  272. 1340            IF (REPLACE.FLAG(I) = FALSE) THEN 1440
  273. 1350                 CHANGED = TRUE
  274. 1360                 FIRST$ = ""
  275. 1370                 IF PTR > 1 THEN FIRST$ = MID$(TEXT.LINE$(J),1,(PTR-1))
  276. 1380                 LAST$ = ""
  277. 1390                 IF (PTR+LEN(FIND.STR$(I))) <= LEN(TEXT.LINE$(J))
  278.                                                             THEN 1420
  279. 1400                     LAST$ = MID$(TEXT.LINE$(J),(PTR+LEN(FIND.STR$(I))))
  280. 1420                 TEXT.LINE$(J) = FIRST$ + REPLACE.STR$(I) + LAST$
  281. 1440             PTR = INSTR(PTR+1,TEXT.LINE$(J),FIND.STR$(I))
  282. 1450        WEND
  283. 1460    NEXT J
  284. 1470  NEXT I
  285. 1480 IF (CHANGED = TRUE) THEN GOSUB 2190 ' WRITE.LINES
  286. 1490 NEXT K
  287. 1500 
  288. 1510 LPRINT CHR$(140) ' form feed
  289. 1520 
  290. 1530 END
  291. 1540 
  292. 1550 '--------------------------------------------------
  293. 1560 ' GET.FILENAMES:  Subroutine to input filenames from the keyboard
  294. 1570 NUM.FILES = 0
  295. 1580 WHILE (NUM.FILES <= 0) OR (NUM.FILES > MAX.FILES)
  296. 1590     INPUT "Enter number of files ";NUM.FILES
  297. 1600     PRINT 
  298. 1610 WEND
  299. 1620 FOR I = 1 TO NUM.FILES
  300. 1630 'REPEAT.LOOP1:
  301. 1640       PRINT "Enter filename # ";I;" ";
  302. 1650       INPUT FILENAME$(I) : PRINT
  303. 1660       ON ERROR GOTO 1750
  304. 1670       OPEN "I",1,FILENAME$(I)
  305. 1680       CLOSE #1
  306. 1690       ON ERROR GOTO 0
  307. 1700    IF FILENAME$(I) = "" THEN 1630
  308. 1710 NEXT I
  309. 1720 RETURN 
  310. 1740 '-------------------------------------------------
  311. 1750 'HANDLE: Error hander for bad filenames
  312. 1760 PRINT "File ";FILENAME$(I);" was not found"
  313. 1770 PRINT
  314. 1780 FILENAME$(I) = ""
  315. 1790 RESUME NEXT
  316. 1800 
  317. 1810 '--------------------------------------------------
  318. 1820 ' GET.STRINGS: Subroutines to input search/replace strings
  319. 1830 NUM.STRINGS = 0
  320. 1840 WHILE (NUM.STRINGS <= 0) OR (NUM.STRINGS > MAX.STRINGS)
  321. 1850     INPUT "Enter number of search/replace strings ";NUM.STRINGS
  322. 1860     PRINT 
  323. 1870 WEND
  324. 1880 FOR I = 1 TO NUM.STRINGS
  325. 1890     REPLACE.STR$(I) = ""
  326. 1900     PRINT : PRINT "For string # ";I
  327. 1910     INPUT "    Enter string ";FIND.STR$(I)
  328. 1920     INPUT "    R)eplace F)ind ";A$ : PRINT
  329. 1930     IF (INSTR("Rr",MID$(A$,1,1)) = 0) THEN REPLACE.FLAG(I) = 
  330.                                     FALSE ELSE REPLACE.FLAG(I) = TRUE
  331. 1980     IF REPLACE.FLAG(I) = FALSE THEN 2020
  332. 1990         INPUT "Enter replacement string ";REPLACE.STR$(I)
  333. 2000         PRINT
  334. 2020 NEXT I
  335. 2030 RETURN
  336. 2040 
  337. 2050 '--------------------------------------------------
  338. 2060 ' READ.LINES: Subroutines to read text lines
  339. 2070 LPRINT
  340. 2080 LPRINT "PROCESSING FILE : ";FILENAME$(K)
  341. 2090 OPEN "I",1,FILENAME$(K)
  342. 2100 NUM.LINES = 0
  343. 2110 WHILE (NOT EOF(1)) AND (NUM.LINES <= MAX.LINES)
  344. 2120    NUM.LINES = NUM.LINES + 1
  345. 2130    LINE INPUT #1,TEXT.LINE$(NUM.LINES)
  346. 2140 WEND
  347. 2150 CLOSE #1
  348. 2160 RETURN  
  349. 2180 '-------------------------------------------------
  350. 2190 ' WRITE.LINES: Subroutines to write text lines
  351. 2200 OPEN "O",1,FILENAME$(K)
  352. 2210 FOR I = 1 TO NUM.LINES
  353. 2220   PRINT #1,TEXT.LINE$(I)
  354. 2230 NEXT I
  355. 2240 CLOSE #1
  356. 2250 RETURN
  357. 2270 '--------------------------------------------------
  358. 2280 ' Subroutine to center a message
  359. 2290 PRINT SPC(40 - LEN(T$)\2);T$
  360. 2300 RETURN
  361.  
  362.  
  363.  
  364.  
  365. Listing 6: Translated C source code for Find/Replace utility.
  366.  
  367. extern int on_error, err_code, err_stmt, trap_line, trap_err; 
  368. char *CHR_(), *MID_(), *s_asgn(), *s_cat(); 
  369. int EOF(), INSTR(), LEN(); 
  370. static int AREPLACE_FLAG[31], changed, false, found, i, j, k, max_files; 
  371. static int max_lines, max_strings, num_files, num_lines, num_strings, ptr; 
  372. static int true; 
  373. static char *FILENAME_[21], *FIND_STR_[31], *REPLACE_STR_[31]; 
  374. static char *TEXT_LINE_[501], *a_, *first_, *last_, *t_; 
  375. static int it_1, it_2, it_3, it_4, it_5, it_6; 
  376. static char *st_1, *st_2; 
  377.  
  378. main(argc, argv) 
  379.     int argc; 
  380.     char *argv[]; 
  381.     { 
  382.     bio_init(argc, argv, 1); 
  383.     /* Batch Find/Replace Utility  Version 1.1  2/7/86 */
  384.     /* IBM PC                  BASICA version 2.0 */
  385.     /* Copyright (c) 1987  Namir Clement Shammas */
  386.     /* --------------------------------------------------- */
  387.     free_sp(FILENAME_, 21, 'S'); 
  388.     free_sp(FIND_STR_, 31, 'S'); 
  389.     free_sp(REPLACE_STR_, 31, 'S'); 
  390.     free_sp(TEXT_LINE_, 501, 'S'); 
  391.     
  392.     true = 1; 
  393.     false = 0; /* Set true/false */
  394.     max_lines = 500; /* Current maximum number of lines read from a file */
  395.     max_strings = 30; /* Number of find/replace strings */
  396.     max_files = 20; /* Maximum number of files */
  397.     CLS(); 
  398.     
  399.     t_ = s_asgn(t_, "\037BATCH FILE FIND/REPLACE PROGRAM"); 
  400.     sub_push(1); 
  401.     goto l_2290; 
  402. g_1:; 
  403.     t_ = s_asgn(t_, "\013VERSION 1.0"); 
  404.     sub_push(2); 
  405.     goto l_2290; 
  406. g_2:; 
  407. E_0:;
  408.     BPRINT(""); 
  409.     if (err_code) {err_stmt=0; goto err_trap;}
  410. E_1:;
  411.     BPRINT(""); 
  412.     if (err_code) {err_stmt=1; goto err_trap;}
  413. E_2:;
  414.     sub_push(3); /* GET.FILENAMES : Get filenames */
  415.     goto l_1560; 
  416. g_3:; 
  417.     sub_push(4); /* GET.STRINGS : Get search/replace strings */
  418.     goto l_1820; 
  419. g_4:; 
  420.     it_1 = num_files; 
  421.     
  422.     for (k = 1; k <= it_1; ++k) 
  423.     { 
  424.     sub_push(5); /* READ.LINES: Read text lines from a file */
  425.     goto l_2060; 
  426. g_5:; 
  427.     changed = false; 
  428.     it_2 = num_strings; 
  429.     
  430.     for (i = 1; i <= it_2; ++i) 
  431.         { 
  432.         found = false; 
  433.         it_3 = num_lines; 
  434.         
  435.         for (j = 1; j <= it_3; ++j) 
  436.         { 
  437. E_3:;
  438.         ptr = INSTR(-1, TEXT_LINE_[j], FIND_STR_[i]); 
  439.     if (err_code) {err_stmt=3; goto err_trap;}
  440. E_4:;
  441.         while (ptr > 0) 
  442.             { 
  443.              if ((found == true)) 
  444.             goto l_1330; 
  445.             found = true; 
  446. E_5:;
  447.             BLPRINT(""); 
  448.     if (err_code) {err_stmt=5; goto err_trap;}
  449. E_6:;
  450.             BLPRINT("s;s", "\012KEYWORD : ", FIND_STR_[i]); 
  451.     if (err_code) {err_stmt=6; goto err_trap;}
  452. E_7:;    
  453.  
  454. l_1330:; 
  455.             BLPRINT("i;s;s", j, "\001:", TEXT_LINE_[j]); 
  456.     if (err_code) {err_stmt=7; goto err_trap;}
  457. E_8:;
  458.              if ((AREPLACE_FLAG[i] == false)) 
  459.             goto l_1440; 
  460.             changed = true; 
  461.             first_ = s_asgn(first_, "\000"); 
  462.              if (ptr > 1) 
  463.             { 
  464. E_9:;
  465.             first_ = s_asgn(first_, MID_(&st_1, TEXT_LINE_[j],
  466.              1, (ptr - 1))); 
  467.     if (err_code) {err_stmt=9; goto err_trap;}
  468. E_10:;
  469.             } 
  470.             last_ = s_asgn(last_, "\000"); 
  471.              if ((ptr + LEN(FIND_STR_[i])) <= LEN(TEXT_LINE_[j])) 
  472.             goto l_1420; 
  473. E_11:;
  474.             last_ = s_asgn(last_, MID_(&st_1, TEXT_LINE_[j], (ptr
  475.              + LEN(FIND_STR_[i])), -1)); 
  476.     if (err_code) {err_stmt=11; goto err_trap;}
  477. E_12:;
  478.             
  479. l_1420:; 
  480.             TEXT_LINE_[j] = s_asgn(TEXT_LINE_[j], s_cat(&st_2, s
  481.                                                                 _cat(&st_1,
  482.              first_, REPLACE_STR_[i]), last_)); 
  483.     if (err_code) {err_stmt=12; goto err_trap;}
  484. E_13:;
  485.             
  486. l_1440:; 
  487.             ptr = INSTR(ptr + 1, TEXT_LINE_[j], FIND_STR_[i]); 
  488.     if (err_code) {err_stmt=13; goto err_trap;}
  489. E_14:;
  490.             } 
  491.         } 
  492.         } 
  493.      if ((changed == true)) 
  494.         { /* WRITE.LINES */
  495.         sub_push(6); /* WRITE.LINES */
  496.         goto l_2190; 
  497. g_6:; 
  498.         } 
  499.     } 
  500. E_15:;
  501.     BLPRINT("s", CHR_(&st_1, 140)); /* form feed */
  502.     if (err_code) {err_stmt=15; goto err_trap;}
  503. E_16:;
  504.         bexit(0); 
  505. /* -------------------------------------------------- */
  506.     
  507. l_1560:; 
  508.     /* GET.FILENAMES:  Subroutine to input filenames from the keyboard */
  509.     num_files = 0; 
  510.     while (-((num_files <= 0)) | -((num_files > max_files))) 
  511.     { 
  512. E_17:;
  513.     INPUT("P ;i", "\026Enter number of files ", &num_files); 
  514.     if (err_code) {err_stmt=17; goto err_trap;}
  515. E_18:;
  516.         BPRINT(""); 
  517.     if (err_code) {err_stmt=18; goto err_trap;}
  518. E_19:;
  519.     } 
  520.     it_4 = num_files; 
  521.     
  522.     for (i = 1; i <= it_4; ++i) 
  523.     { 
  524.     
  525. l_1630:; 
  526.     /* REPEAT.LOOP1: */
  527. E_20:;
  528.     BPRINT("s;i;s;", "\021Enter filename # ", i, "\001 "); 
  529.     if (err_code) {err_stmt=20; goto err_trap;}
  530. E_21:;
  531.         INPUT(" s", &FILENAME_[i]); 
  532.     if (err_code) {err_stmt=21; goto err_trap;}
  533. E_22:;
  534.         BPRINT(""); 
  535.     if (err_code) {err_stmt=22; goto err_trap;}
  536. E_23:;
  537.     on_error = 1; 
  538.     err_code = 0; 
  539.     trap_line = 1; 
  540. E_24:;
  541.     BOPEN("\001I", 1, FILENAME_[i], -1); 
  542.     if (err_code) {err_stmt=24; goto err_trap;}
  543. E_25:;
  544.         BCLOSE(1, 0); 
  545.     if (trap_err) 
  546.         { 
  547.         xer_msg(trap_err); 
  548.         bexit(1); 
  549.         } 
  550.     on_error = 0; 
  551.     err_code = 0; 
  552.      if (s_comp(FILENAME_[i], "\000") == 0) 
  553.         goto l_1630; 
  554.     } 
  555.     goto sub_ret; 
  556. /* ------------------------------------------------- */
  557.  
  558. l_1750:; 
  559.     /* HANDLE: Error hander for bad filenames */
  560. E_26:;
  561.     BPRINT("s;s;s", "\005File ", FILENAME_[i], "\016 was not found"); 
  562.     if (err_code) {err_stmt=26; goto err_trap;}
  563. E_27:;
  564.     BPRINT(""); 
  565.     if (err_code) {err_stmt=27; goto err_trap;}
  566. E_28:;
  567.     FILENAME_[i] = s_asgn(FILENAME_[i], "\000"); 
  568.     ++err_stmt; 
  569.     goto un_trap; 
  570. /* -------------------------------------------------- */
  571.     
  572. l_1820:; 
  573.     /* GET.STRINGS: Subroutines to input search/replace strings */
  574.     num_strings = 0; 
  575.     while (-((num_strings <= 0)) | -((num_strings > max_strings))) 
  576.     { 
  577. E_29:;
  578.     INPUT("P ;i", "\047Enter number of search/replace strings ",
  579.                                                     &num_strings); 
  580.     if (err_code) {err_stmt=29; goto err_trap;}
  581. E_30:;
  582.     BPRINT(""); 
  583.     if (err_code) {err_stmt=30; goto err_trap;}
  584. E_31:;
  585.         } 
  586.     it_5 = num_strings; 
  587.     
  588.     for (i = 1; i <= it_5; ++i) 
  589.     { 
  590.     REPLACE_STR_[i] = s_asgn(REPLACE_STR_[i], "\000"); 
  591. E_32:;
  592.     BPRINT(""); 
  593.     if (err_code) {err_stmt=32; goto err_trap;}
  594. E_33:;
  595.     BPRINT("s;i", "\015For string # ", i); 
  596.     if (err_code) {err_stmt=33; goto err_trap;}
  597. E_34:;
  598.     INPUT("P ;s", "\021    Enter string ", &FIND_STR_[i]); 
  599.     if (err_code) {err_stmt=34; goto err_trap;}
  600. E_35:;
  601.     INPUT("P ;s", "\023    R)eplace F)ind ", &a_); 
  602.     if (err_code) {err_stmt=35; goto err_trap;}
  603. E_36:;
  604.     BPRINT(""); 
  605.     if (err_code) {err_stmt=36; goto err_trap;}
  606. E_37:;
  607.          if ((INSTR(-1, "\002Rr", MID_(&st_1, a_, 1, 1)) == 0)) 
  608.         { 
  609.         AREPLACE_FLAG[i] = false; 
  610.         } 
  611.      else 
  612.         { 
  613.         AREPLACE_FLAG[i] = true; 
  614.         } 
  615.      if (AREPLACE_FLAG[i] == false) 
  616.         goto l_2020; 
  617. E_38:;
  618.     INPUT("P ;s", "\031Enter replacement string ", &REPLACE_STR_[i]); 
  619.     if (err_code) {err_stmt=38; goto err_trap;}
  620. E_39:;
  621.     BPRINT(""); 
  622.     if (err_code) {err_stmt=39; goto err_trap;}
  623. E_40:;
  624.  
  625. l_2020:; 
  626.     } 
  627.     goto sub_ret; 
  628. /* -------------------------------------------------- */
  629.     
  630. l_2060:; 
  631.     /* READ.LINES: Subroutines to read text lines */
  632. E_41:;
  633.     BLPRINT(""); 
  634.     if (err_code) {err_stmt=41; goto err_trap;}
  635. E_42:;
  636.     BLPRINT("s;s", "\022PROCESSING FILE : ", FILENAME_[k]); 
  637.     if (err_code) {err_stmt=42; goto err_trap;}
  638. E_43:;
  639.     BOPEN("\001I", 1, FILENAME_[k], -1); 
  640.     if (err_code) {err_stmt=43; goto err_trap;}
  641. E_44:;
  642.         num_lines = 0; 
  643.     while ((~(EOF(1))) & -((num_lines <= max_lines))) 
  644.     { 
  645.     num_lines = num_lines + 1; 
  646. E_45:;
  647.     INPUT("FLl", 1, &TEXT_LINE_[num_lines]); 
  648.     if (err_code) {err_stmt=45; goto err_trap;}
  649. E_46:;
  650.         } 
  651.     BCLOSE(1, 0); 
  652.     goto sub_ret; 
  653. /* ------------------------------------------------- */
  654.     
  655. l_2190:; 
  656.     /* WRITE.LINES: Subroutines to write text lines */
  657. E_47:;
  658.     BOPEN("\001O", 1, FILENAME_[k], -1); 
  659.     if (err_code) {err_stmt=47; goto err_trap;}
  660. E_48:;
  661.     it_6 = num_lines; 
  662.     
  663.     for (i = 1; i <= it_6; ++i) 
  664.     { 
  665. E_49:;
  666.     BFPRINT(1, "s", TEXT_LINE_[i]); 
  667.     if (err_code) {err_stmt=49; goto err_trap;}
  668. E_50:;    } 
  669.     BCLOSE(1, 0); 
  670.     goto sub_ret; 
  671. /* -------------------------------------------------- */
  672.     /* Subroutine to center a message */
  673. E_51:;
  674.  
  675. l_2290:; 
  676.     BPRINT("b;s", 40 - LEN(t_) / 2, t_); 
  677.     if (err_code) {err_stmt=51; goto err_trap;}
  678. E_52:;
  679.     goto sub_ret; 
  680.     bexit(0); 
  681.  
  682.     sub_ret: 
  683.     switch(sub_pop())  
  684.     { 
  685.     case 1: goto g_1; 
  686.     case 2: goto g_2; 
  687.     case 3: goto g_3; 
  688.     case 4: goto g_4; 
  689.     case 5: goto g_5; 
  690.     case 6: goto g_6; 
  691.     } 
  692.     
  693. err_trap: if (trap_err) 
  694.     { 
  695.     xer_msg(err_code); 
  696.     bexit(1); 
  697.     } 
  698.     trap_err = err_code; 
  699.     err_code = 0; 
  700.     goto l_1750; 
  701.     
  702. un_trap: if (!trap_err) 
  703.     { 
  704.     xer_msg(-99); 
  705.     bexit(1); 
  706.     } 
  707.     trap_err = err_code = 0; 
  708.     switch(err_stmt) 
  709.     { 
  710.     case 0: goto E_0; 
  711.     case 1: goto E_1; 
  712.     case 2: goto E_2; 
  713.     case 3: goto E_3; 
  714.     case 4: goto E_4; 
  715.     case 5: goto E_5; 
  716.     case 6: goto E_6; 
  717.     case 7: goto E_7; 
  718.     case 8: goto E_8; 
  719.     case 9: goto E_9; 
  720.     case 10: goto E_10; 
  721.     case 11: goto E_11; 
  722.     case 12: goto E_12; 
  723.     case 13: goto E_13; 
  724.     case 14: goto E_14; 
  725.     case 15: goto E_15; 
  726.     case 16: goto E_16; 
  727.     case 17: goto E_17; 
  728.     case 18: goto E_18; 
  729.     case 19: goto E_19; 
  730.     case 20: goto E_20; 
  731.     case 21: goto E_21; 
  732.     case 22: goto E_22; 
  733.     case 23: goto E_23; 
  734.     case 24: goto E_24; 
  735.     case 25: goto E_25; 
  736.     case 26: goto E_26; 
  737.     case 27: goto E_27; 
  738.     case 28: goto E_28; 
  739.     case 29: goto E_29; 
  740.     case 30: goto E_30; 
  741.     case 31: goto E_31; 
  742.     case 32: goto E_32; 
  743.     case 33: goto E_33; 
  744.     case 34: goto E_34; 
  745.     case 35: goto E_35; 
  746.     case 36: goto E_36; 
  747.     case 37: goto E_37; 
  748.     case 38: goto E_38; 
  749.     case 39: goto E_39; 
  750.     case 40: goto E_40; 
  751.     case 41: goto E_41; 
  752.     case 42: goto E_42; 
  753.     case 43: goto E_43; 
  754.     case 44: goto E_44; 
  755.     case 45: goto E_45; 
  756.     case 46: goto E_46; 
  757.     case 47: goto E_47; 
  758.     case 48: goto E_48; 
  759.     case 49: goto E_49; 
  760.     case 50: goto E_50; 
  761.     case 51: goto E_51; 
  762.     case 52: goto E_52; 
  763.     } 
  764.     } 
  765.  
  766.  
  767.